<template>
  <div class="wrap">
    <ul class="page">
      <li
        v-for="i in num"
        :key="i"
        @click="getpage(i)"
        :class="{ active: flag == i }"
      >
        {{ i }}
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  props: ["total", "pagesize"],
  data() {
    return {
      flag: 1,
    };
  },
  computed: {
    num() {
      return Math.ceil(this.total / this.pagesize);
    },
  },
  mounted() {},
  methods: {
    getpage(i) {
      this.$emit("currentchange", i);
      this.flag = i;
    },
  },
  components: {},
};
</script>

<style lang="scss">
.wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  .page {
    display: flex;
    li {
      width: 30px;
      height: 30px;
      margin: 15px;
      text-align: center;
      line-height: 30px;
      background: #ccc;
      color: brown;
    }
    .active {
      background: brown;
      color: #ccc;
    }
  }
}
</style>
